package demo.model;

import org.hibernate.validator.constraints.Length;

import javax.persistence.Entity;
import javax.persistence.Id;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Pattern;

/**
 * 学院对象，与college表对应
 */
@Entity
public class College {
    @Id
    @NotBlank(message = "学院代码不能为空")
    @Pattern(regexp = "^\\d+$", message = "学院代码至少1位数字")
    private String id;

    @NotBlank(message = "学院名称不能为空")
    @Length(min = 2, max = 20, message = "学院名称2-20个字符")
    private String name;

    public College() {
    }

    public College(String id, String name) {
        this.id = id;
        this.name = name;
    }

    public String getId() {
        return id;
    }

    public void setId(String collegeId) {
        this.id = collegeId;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    @Override
    public String toString() {
        return "College{" +
                "id='" + id + '\'' +
                ", name='" + name + '\'' +
                '}';
    }
}
